#ifndef CAMERAVIDEOCAPTURE_H
#define CAMERAVIDEOCAPTURE_H

#include <QObject>
#include "modules/video_capture/video_capture.h"
#include "api/video/video_source_interface.h"
#include "api/video/video_frame.h"

class CameraVideoCapture
        : public QObject,
        public rtc::VideoSourceInterface<webrtc::VideoFrame>,
        public rtc::VideoSinkInterface<webrtc::VideoFrame>
{
    Q_OBJECT
public:
    explicit CameraVideoCapture(QObject *parent = nullptr);
    virtual ~CameraVideoCapture();

    bool init(const int& iWidth, const int& iHeight, const int& iFPS, const QString& strID);


    virtual void AddOrUpdateSink(VideoSinkInterface<webrtc::VideoFrame>* sink,
                                 const rtc::VideoSinkWants& wants) override;
    virtual void RemoveSink(VideoSinkInterface<webrtc::VideoFrame>* sink) override;

    virtual void OnFrame(const webrtc::VideoFrame& frame) override;

private:
    void destroy();



Q_SIGNALS:

private:
    rtc::scoped_refptr<webrtc::VideoCaptureModule> m_modulePtr;
    webrtc::VideoCaptureCapability              m_capability;

};

#endif // CAMERAVIDEOCAPTURE_H
